<template>
  <div class="swiper">
    <swiper :ref="swriperName" :options="swiperOption" >
      <swiper-slide
        class="swiper-slide-wrap"
        @slideChange="swriperName=='mySwriper2'?change():''"
        v-for="(item,index) in proItem"
        :key="item"
        v-if="item.isShow != 0"
        >
<!--        :style="{backgroundImage: 'url('+require('../assets/logo.png')+')'}"-->
        <div class="swiperCon" v-if="type=='img'" @click="todetail(item)">
          <div class="imgBox">
              <img :src="item.cover" alt="">
            </div>
          <div class="swiperC">
            <p>
              {{item.title}}
            </p>
            <!-- <p>
              主讲：{{item.author}}
            </p> -->
          </div>
        </div>
        <div class="swiperCon" v-if="type=='image'"  @click="toNotice(item,index)">
          <img class="newImg" :style="{height:!height?'auto':height}" :src="item.cover" alt="">
        </div>
        <div :class="['swiperCon', 'domCon',{'active':imgIndex==index}]" v-if="type=='dom'">
          <p class="domTitle">{{item.title}}</p>
          <p class="domData">
            <span>{{item.data}}</span>
            <img :src="item.img" alt="">
          </p>
          <p class="domDes">
            {{item.plan}}
          </p>
        </div>
      </swiper-slide>
      <div v-if="isNavigation" class="swiper-button-next" slot="button-prev"></div>
      <div v-if="isNavigation" class="swiper-button-prev" slot="button-next"></div>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
  import Vue from 'vue'
  import VueAwesomeSwiper from 'vue-awesome-swiper'
  Vue.use(VueAwesomeSwiper)
  import { swiper, swiperSlide } from 'vue-awesome-swiper'
  import 'swiper/dist/css/swiper.css'
  export default {
    props:{
      type:String,
      proItem:Array,
      isNav:Boolean,
      thisSwiper: Object,
      swriperName:String,
      height:String
    },
    data(){
      return{
        per:this.thisSwiper,
        isNavigation:this.isNav,
        swiperOption:this.thisSwiper,
        imgIndex:0,
        loadList: false
      }
    },
    components:{
      swiper,
      swiperSlide
    },
    methods:{
      change() {
        this.imgIndex = this.$refs.mySwiper2.swiper.activeIndex;
      },
      todetail(item) {
          // console.log(item.id)
        this.$router.push({path: '/supervise/study',
            query:{
                isDetail: true,
                data: item.id
            }}
        );
      },
      toNotice(item,index) {
        this.$emit('toNotice', item, index, this.proItem, '新闻资讯')
      },
    }
  }
</script>
<style scoped>
  .swiper-container {
    width: 100%;
    padding-bottom: 15px;
    min-height: 150px;
  }

  .swiper-pagination .swiper-pagination-bullet-active{
    background-color: #F29B76;
  }
  .swiperCon{
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-top: 16px;
    cursor: pointer;
  }
  .swiperCon .imgBox img{
    width: 100%;
    height: 120px;
    display: block;
    border-radius: 10px;
  }
  .swiper-button-prev,.swiper-button-next{
    width: 32px;
    height: 32px;
  }

  .swiper-button-next{
    background:url("../../public/img/commImg/right.png") 0 0/100% 100% no-repeat;
  }
  .domCon{
    background: url("../../public/img/commImg/bg-default.png") 0 0/100% 100% no-repeat;
    padding: 12px 20px;
    box-sizing: border-box;
  }
  .domCon:hover{
    background: url("../../public/img/commImg/bg-active.png") 0 0/100% 100% no-repeat;
  }
  .domCon p{
    /*margin: 0;*/
  }
  .domTitle{
    font-size: 12px;
    font-weight: 500;
    color: #34404B;
    line-height: 13px;
  }
  .domData{
    display: flex;
    justify-content: space-between;
    font-size: 28px;
    font-family: Helvetica;
    color: #11212F;
    text-align: center;
    align-items: center;
  }
  .domData span{
    flex: 1;
    white-space: nowrap;
    text-align: left;
  }
  .domData img{
    width: 48px;
    height: 48px;
  }
  .domDes{
    font-size: 12px;
    font-weight: 400;
    color: #AFB4B9;
    line-height: 12px;
    margin-bottom: 12px;
    overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
  }
  .swiper-pagination-bullets{
    bottom: 0;
  }
  .swiper-slide-wrap {
      /* margin-right: 10px; */
  }
  .newImg {
      /*width: 400px;*/
      height: 200px;
      object-fit: cover;
  }
</style>
